package com.cefa.edu.util;

import java.time.Instant;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by qimwang on 8/3/17.
 */
public class TimeUtil {

    public static Integer getCurrentYear(){

        Calendar calendar=Calendar.getInstance();
        calendar.setTime(new Date());
        Integer currentYear=calendar.get(Calendar.YEAR);
        return currentYear;
    }

    public static long interval(String from, String to) {
        LocalDate start = LocalDate.parse(from);
        LocalDate end = LocalDate.parse(to);


        return start.until(end, ChronoUnit.DAYS);
    }

    public static void main(String args[]) {
        long requestTime = Instant.now().toEpochMilli() / 1000;
        String a = "f09ddf818db02d184d3848f08d475782";

        System.out.println((int)a.charAt(0));

        int sum = 0;
        for(int i = 0; i < a.length(); i++) {
            sum += (int)a.charAt(i);
        }
        System.out.println("sum " + sum);
        System.out.println("index " + sum % 1024);
    }
}
